package com.zyc.studentstudy.ui.youdao

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.zyc.studentstudy.databinding.FragmentYoudaolistBinding
import com.zyc.studentstudy.simple.SimpleFragment
import com.zyc.studentstudy.utils.FragmentsUtil

/**
 * Created by zhangyuncai on 2025/10/14.
 * 描述：有道列表
 */
class YoudaoListFragment : SimpleFragment() {

    private lateinit var mDB: FragmentYoudaolistBinding

    override fun useDatabing(inflater: LayoutInflater, container: ViewGroup?): View? {
        mDB = FragmentYoudaolistBinding.inflate(inflater, container, false)
        return mDB.root
    }

    override fun lazyFetchData() {
        val fragments = mutableListOf<Fragment>()
        YoudaoHolder.cidianFragment =
            FragmentsUtil.sNewStance(mContext, CidianFragment::class.java) as CidianFragment
        YoudaoHolder.fanyiFragment =
            FragmentsUtil.sNewStance(mContext, FanyiFragment::class.java) as FanyiFragment
        fragments.add(YoudaoHolder.cidianFragment)
        fragments.add(YoudaoHolder.fanyiFragment)
        val pagerAdapter = YoudaoListAdapter(fragments, childFragmentManager, lifecycle)
        mDB.vpYoudaolist.apply {
            adapter = pagerAdapter
            offscreenPageLimit = fragments.size
        }
    }

    override fun initView() {

    }

    override fun initEvent() {
    }
}